

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The interrupt module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../index.html" />
    <link rel="up" title="The qt module" href="mod_pyamp_ui_qt.html" />
    <link rel="next" title="The keyEvents module" href="pyamp_ui_qt_keyEvents.html" />
    <link rel="prev" title="The baseWidget module" href="pyamp_ui_qt_baseWidget.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_keyEvents.html" title="The keyEvents module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_baseWidget.html" title="The baseWidget module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui.html" >The ui module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui_qt.html" accesskey="U">The qt module</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.ui.qt.interrupt">
<span id="the-interrupt-module"></span><h1>The interrupt module<a class="headerlink" href="#module-pyamp.ui.qt.interrupt" title="Permalink to this headline">¶</a></h1>
<p>The interrupt module contains the InterruptThread class which provides
a Thread which will periodically notify a QWidget.</p>
<div class="section" id="the-interruptable-class">
<h2>The Interruptable class<a class="headerlink" href="#the-interruptable-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-91f8b44d966a5d5d68dfe81c4031697636f49478.png" alt="Inheritance diagram of pyamp.ui.qt.interrupt.Interruptable" usemap="#inheritanceea3fd74dbe" class="inheritance"/>
<map id="inheritanceea3fd74dbe" name="inheritanceea3fd74dbe">
<area shape="rect" href="#pyamp.ui.qt.interrupt.Interruptable" title="pyamp.ui.qt.interrupt.Interruptable" alt="" coords="5,7,248,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.ui.qt.interrupt.Interruptable">
<em class="property">class </em><tt class="descclassname">pyamp.ui.qt.interrupt.</tt><tt class="descname">Interruptable</tt><big>(</big><em>period=0.10000000000000001</em><big>)</big><a class="reference internal" href="../_modules/pyamp/ui/qt/interrupt.html#Interruptable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.ui.qt.interrupt.Interruptable" title="Permalink to this definition">¶</a></dt>
<dd><p>The Interruptable class provides an interface for interrupting
a class at a specific interval.</p>
<p>This class created an <a class="reference internal" href="#pyamp.ui.qt.interrupt.InterruptThread" title="pyamp.ui.qt.interrupt.InterruptThread"><tt class="xref py py-class docutils literal"><span class="pre">InterruptThread</span></tt></a> object which notifies
the <a class="reference internal" href="#pyamp.ui.qt.interrupt.Interruptable.interrupt" title="pyamp.ui.qt.interrupt.Interruptable.interrupt"><tt class="xref py py-func docutils literal"><span class="pre">interrupt()</span></tt></a> function at the specified <tt class="xref py py-attr docutils literal"><span class="pre">period</span></tt>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Example</span><span class="p">(</span><span class="n">Interruptable</span><span class="p">):</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">Interruptable</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">period</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span>

    <span class="c"># This function is called once per second, and i is the current</span>
    <span class="c"># iteration number.</span>
    <span class="k">def</span> <span class="nf">interrupt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
        <span class="k">print</span> <span class="n">i</span>
</pre></div>
</div>
<ul class="simple">
<li>period &#8211; The number of seconds to sleep during each cycle</li>
</ul>
<dl class="method">
<dt id="pyamp.ui.qt.interrupt.Interruptable.interrupt">
<tt class="descname">interrupt</tt><big>(</big><em>_i</em><big>)</big><a class="reference internal" href="../_modules/pyamp/ui/qt/interrupt.html#Interruptable.interrupt"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.ui.qt.interrupt.Interruptable.interrupt" title="Permalink to this definition">¶</a></dt>
<dd><p>Override the interrupt function. This function is called once
per cycle of the <a class="reference internal" href="#pyamp.ui.qt.interrupt.InterruptThread" title="pyamp.ui.qt.interrupt.InterruptThread"><tt class="xref py py-class docutils literal"><span class="pre">InterruptThread</span></tt></a>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function should be overridden by subclasses.</p>
</div>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="the-interruptthread-class">
<h2>The InterruptThread class<a class="headerlink" href="#the-interruptthread-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-16776469c6019ab95c7b71738b08260dbdcb1349.png" alt="Inheritance diagram of pyamp.ui.qt.interrupt.InterruptThread" usemap="#inheritance402f1a0972" class="inheritance"/>
<map id="inheritance402f1a0972" name="inheritance402f1a0972">
<area shape="rect" href="#pyamp.ui.qt.interrupt.InterruptThread" title="pyamp.ui.qt.interrupt.InterruptThread" alt="" coords="5,316,264,343"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.ui.qt.interrupt.InterruptThread">
<em class="property">class </em><tt class="descclassname">pyamp.ui.qt.interrupt.</tt><tt class="descname">InterruptThread</tt><big>(</big><em>parent</em>, <em>period=None</em><big>)</big><a class="reference internal" href="../_modules/pyamp/ui/qt/interrupt.html#InterruptThread"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.ui.qt.interrupt.InterruptThread" title="Permalink to this definition">¶</a></dt>
<dd><p>The InterruptThread class implements a <tt class="xref py py-class docutils literal"><span class="pre">PyQt4.Qt.QThread</span></tt> to call
the <strong>interrupt</strong> function of a given object at a specifiable rate.</p>
<p>The InterruptThread class can define the <a class="reference internal" href="#pyamp.ui.qt.interrupt.InterruptThread.period" title="pyamp.ui.qt.interrupt.InterruptThread.period"><tt class="xref py py-attr docutils literal"><span class="pre">period</span></tt></a> property to
determine the number of seconds the <tt class="xref py py-class docutils literal"><span class="pre">PyQt4.Qt.QThread</span></tt> will sleep
during each iteration. The default <a class="reference internal" href="#pyamp.ui.qt.interrupt.InterruptThread.period" title="pyamp.ui.qt.interrupt.InterruptThread.period"><tt class="xref py py-attr docutils literal"><span class="pre">period</span></tt></a> is 0.1 seconds.</p>
<p>This class throws an <tt class="xref py py-class docutils literal"><span class="pre">amp.exceptions.UndefinedFunctionError</span></tt> in the
event that the <strong>interrupt</strong> function is not defined by the <tt class="xref py py-attr docutils literal"><span class="pre">parent</span></tt>
object.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <strong>interrupt</strong> function takes one parameter which is the
current interation number that the interrupt thread is on. The
iteration number increases once per cycle.</p>
</div>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Example</span><span class="p">():</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__interrupt</span> <span class="o">=</span> <span class="n">InterruptThread</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">period</span><span class="o">=</span><span class="mf">0.5</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__interrupt</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">interrupt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
        <span class="k">print</span> <span class="n">i</span>
</pre></div>
</div>
<ul class="simple">
<li>parent &#8211; The parent of this thread.</li>
<li>period &#8211; The number of seconds to sleep between each interrupt</li>
</ul>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The <tt class="xref py py-attr docutils literal"><span class="pre">parent</span></tt> object must have a function named
<strong>interrupt</strong> defined.</p>
</div>
<dl class="attribute">
<dt id="pyamp.ui.qt.interrupt.InterruptThread.period">
<tt class="descname">period</tt><a class="headerlink" href="#pyamp.ui.qt.interrupt.InterruptThread.period" title="Permalink to this definition">¶</a></dt>
<dd><p>Definine the number of seconds the <tt class="xref py py-class docutils literal"><span class="pre">PyQt4.Qt.QThread</span></tt> will sleep
between each cycle, prior to interrupting the <tt class="xref py py-attr docutils literal"><span class="pre">parent</span></tt> object.</p>
</dd></dl>

<dl class="method">
<dt id="pyamp.ui.qt.interrupt.InterruptThread.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="../_modules/pyamp/ui/qt/interrupt.html#InterruptThread.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.ui.qt.interrupt.InterruptThread.run" title="Permalink to this definition">¶</a></dt>
<dd><p>Run the interrupt thread.</p>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The interrupt module</a><ul>
<li><a class="reference internal" href="#the-interruptable-class">The Interruptable class</a></li>
<li><a class="reference internal" href="#the-interruptthread-class">The InterruptThread class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="pyamp_ui_qt_baseWidget.html"
                        title="previous chapter">The baseWidget module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="pyamp_ui_qt_keyEvents.html"
                        title="next chapter">The keyEvents module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/_generated/pyamp_ui_qt_interrupt.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_keyEvents.html" title="The keyEvents module"
             >next</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_baseWidget.html" title="The baseWidget module"
             >previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui.html" >The ui module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui_qt.html" >The qt module</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>